package com.example.demo.testController;

import com.example.demo.model.ApiResponse;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/test")
@CrossOrigin
public class TestController {

    @GetMapping("/ping")
    public ApiResponse<String> ping() {
        return ApiResponse.success("pong");
    }

    @GetMapping("/success")
    public ApiResponse<String> successResponse() {
        return ApiResponse.success("This is a successful response");
    }

    @GetMapping("/failure")
    public ApiResponse<String> failureResponse() {
        return ApiResponse.failure(400, "ERR_CODE", "This is a failure response");
    }
}
